package com.example.demo.service.impl;

import com.example.demo.dao.Indent;


import com.example.demo.dao.SearchIndentResponse;
import com.example.demo.mapper.IndentMapper;
import com.example.demo.service.indentService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class indentServiceImpl implements indentService {
    @Autowired
    private IndentMapper indentMapper;
    @Override
    public List<Indent> findIsendIndent() {
        List<Indent> list = indentMapper.getAll();
        return list;
    }

    @Override
    public int delectIndent(Integer id) {
        int deletedata= indentMapper.deleteByPrimaryKey(id);
        return deletedata;
    }
    //查询未发货订单商品
//    @Override
//    public SearchIndentResponse findgoods(Integer pageNum,Integer pageSize) {
//        PageHelper.startPage(pageNum ,pageSize);
//        List<Indent> indents = indentMapper.goodsAll();
//        return new SearchIndentResponse(((Page)indents).getTotal(),indents);
//    }
 //  修改发货信息
    @Override
    public int uodateIssent(Integer id) {
        int update =indentMapper.updateIssend(id);
        return update;
    }
 //未收货商品地址信息
    @Override
    public SearchIndentResponse searchIndent1(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum ,pageSize);
        List<Indent> indents = indentMapper.getAll1();
        return new SearchIndentResponse(((Page)indents).getTotal(),indents);
    }

    @Override
    public SearchIndentResponse searchIndent2(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Indent> indents = indentMapper.getAll2();
        return new SearchIndentResponse(((Page)indents).getTotal(),indents);
    }

    //前端点击添加订单
    @Override
    public int addIndent(Indent indent) {
        return indentMapper.insert(indent);
    }

    @Override
    public List<Indent> findIndentByUser(Integer id) {
        return indentMapper.getIndentByUser(id);
    }

    @Override
    public Indent findIndentById(Integer id) {
        return indentMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateIndent(Indent indent) {
        return indentMapper.updateByPrimaryKeySelective(indent);
    }

    //8-12
    @Override
    public List<Indent> findAll() {
        return indentMapper.findAll();
    }

    @Override
    public List<Indent> findNoPay() {
        return indentMapper.findNopay();
    }

    @Override
    public List<Indent> findNoSend() {
        return indentMapper.findNosend();
    }

    @Override
    public List<Indent> findNoReceive() {
        return indentMapper.findNoreceive();
    }

    @Override
    public List<Indent> findNoComplete() {
        return indentMapper.findNocomplete();
    }

    //未收货商品信息
//    @Override
//    public SearchIndentResponse findgoods1(Integer pageNum, Integer pageSize) {
//        PageHelper.startPage(pageNum ,pageSize);
//        List<Indent> indents = indentMapper.goodsAll1();
//        return new SearchIndentResponse(((Page)indents).getTotal(),indents);
//    }

    @Override
    //查询未发货订单
    public SearchIndentResponse searchIndent(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum ,pageSize);
        List<Indent> indents=indentMapper.getAll();
        return new SearchIndentResponse(((Page)indents).getTotal(),indents);
    }
//    @Override
//    public SearchIndentResponse searchIndent(Integer pageNum , Integer pageSize){
//        PageHelper.startPage(pageNum,pageSize);
//        IndentExample indentExample = new IndentExample();
//        IndentExample.Criteria criteria = indentExample.createCriteria();
//        criteria.andIssendEqualTo(0);
//        List<Indent> list = indentMapper.selectByExample(indentExample);
//        return new SearchIndentResponse(((Page)list).getTotal(),list);
//
//    }
}
